from amscms import settings
from amscms.dict.managers import TermManager
from django.db import models
from django.utils.translation import ugettext as _

"""
Language definition.

@author: Behrooz Nobakht
"""
class Language(models.Model):
    id = models.AutoField(primary_key=True, verbose_name=_("Id"))
    code = models.CharField(unique=True, max_length=2, verbose_name=_("Code"), default=settings.LANGUAGE_CODE)
    name = models.CharField(verbose_name=_("Name"), max_length=32)
    
    def __unicode__(self):
        return self.name + "(" + self.code + ")"
    
    class Meta:
        db_table = "dict_lang"
        verbose_name = _("Language")
        verbose_name_plural = _("Languages")


"""
The basic definition of a word in a dictionary

@author: Behrooz Nobakht
"""
class Term(models.Model):
    id = models.AutoField(primary_key=True, verbose_name=_("Id"))
    term = models.CharField(unique=True, max_length=64, verbose_name=_("Term"), db_index=True)
    frequency = models.IntegerField(blank=True, default=0)
    language = models.ForeignKey(Language)
    enabled = models.BooleanField(verbose_name=_("Enabled"), default=True)
    reviewed = models.BooleanField(verbose_name=_("Reviewed"), default=False)
    objects = TermManager()
    
    def __unicode__(self):
        return self.term
    
    class Meta:
        db_table = "dict_term"
        verbose_name = _("Term")
        verbose_name_plural = _("Terms")

    
        
    
